package com.coder.bike.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.coder.bike.entity.BikeInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 沈诩宸
 * @since 2025-04-22
 */
public interface BikeInfoMapper extends BaseMapper<BikeInfo> {
    Page<BikeInfo> searchByPage(Page<BikeInfo> page, @Param("bikeInfo") BikeInfo bikeInfo);
    Map<String, Integer> getStatusCount();
    @Select("SELECT * FROM bike_info WHERE bike_num = #{bikeId}")
    BikeInfo selectByBikeId(String bikeId);

    @Select("SELECT * FROM bike_info WHERE last_maintain IS NULL OR last_maintain < #{date} ORDER BY bike_num")
    List<BikeInfo> selectToBeMaintained(LocalDateTime date);
}
